<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>策略模式</title>
</head>

<body>

</body>
<script>
    const strategy_number = {
        "A": function (number) {
            console.log('这是A');
            return number + 5
        },
        '编辑': function (number) {
            console.log('这是B');
            return number
        },
        'C': function (number) {
            console.log('这是C');
            return number - 2
        }
    }
    function name_number(params, number) {
      return    strategy_number[params](number)
    }
    console.log(name_number('A',5))
    console.log(name_number('编辑','测试'))
    console.log(name_number('C',6))
</script>

</html>